﻿namespace IteratorDemo
{
    internal class ListIterator : IIterator
    {
        private ListAggregate aggregate;
        private int currentIndex;
        public ListIterator(ListAggregate aggregate)
        {
            this.aggregate = aggregate;
            this.currentIndex = -1;
        }

        public int GetCurrent()
        {
            return aggregate[currentIndex];
        }

        public bool MoveNext()
        {
            if (currentIndex + 1 < aggregate.Count)
            {
                currentIndex++;
                return true;
            }
            return false;
        }
    }
}
